using EnvDTE;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestCommand.Helper
{
    public static class VSHelper
    {
        public static string GetSelectedItemInfoInSolutionExplorerCs(EnvDTE80.DTE2 dte)
        {
            var toolWindow = dte.ToolWindows;

            var solutionExplorer = toolWindow.SolutionExplorer;

            var selectedItems = (solutionExplorer.SelectedItems as IEnumerable).OfType<UIHierarchyItem>().Select(i => i.Object).OfType<ProjectItem>();
            var selectedItem = selectedItems.FirstOrDefault();

            if (selectedItem == null) return null;

            var project = selectedItem.ContainingProject;
            var projectFullName = project.FullName;
            var itemPath = selectedItem.FileNames[0];

            return itemPath;
        }


    }
}
